<template>
	<view class="team-box">
		<view class="team-info">
			<view class="team-avatar"><image :src="userinfo.user_headimg" class="team-avatar"></image></view>
			<view class="team-nickname">
				 <view class="">
					 {{userinfo.nick_name}}
				 </view>
				 <view>
					 部门规模:{{count}}
				 </view>
			</view>
		</view>
		<view class="team-list">
			 <view class="item-list-block" v-for="(item, index) in teamList" :key="index"> 
				<view class="item-info">
					<view class="item-faces"><image :src="item.user_headimg" class="team-avatar"></image></view>
					<view class="item-name">
						<view class="item-name-nick">
							<view class="level_name tui-noraml" v-if="item.member_level==49">创</view>
							<view class="level_name tui-warning" v-else-if="item.member_level==48">V</view>
							<view class="level_name tui-danger" v-else>普</view>
							{{item.nick_name}}</view>
						<view class="item-name-mobile">{{item.user_tel}}</view>
					</view>
					<view class="item-time">{{item.reg_time}}</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				error: true,
				msg: null,
				teamList:'',
				userinfo:'',
				count:'',
			}
		},
		onShow() {
			this.tui.haslogin();
			if(this.tui.isLogin()){
				this.init();
			}
			this.userinfo = this.tui.getUserInfoData();
		},
		onPullDownRefresh() {
			this.init();			
		},
		methods: {
           init(){
			   let token = this.tui.getToken();
			   let datas={
			   	token: token,
			   };
			   let result=this.tui.request('user','post',datas,1000,1,'','myTeam');
			   Promise.resolve(result).then((value)=>{
			      if(value.code==10000){
			      	this.teamList=value.data.child;
					this.count=value.data.my_info.count;
			   	//写入缓存
			      }else{
			      	this.tui.toast(value.message);
			      }
			   })
		   }

		}
	}
</script>

<style>
	@import '../../static/css/yisyui.css';
	page {
		background-color: #F5F5F5;
	}
	
	.tui-content-box {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
	/* 	top: -72rpx; */
		z-index: 10;
	}
	.team-box{
        position: relative;
	}
	.team-info{
		background-image: linear-gradient(to bottom right, #ef4820, #e41f19);
		height: 300rpx;
		color:#fff;
		width: 100%;
		padding: 0 30rpx;
		font-size: 30rpx;
		display: flex;
		box-sizing: border-box;
		align-items: center;
		justify-content:center;
	}
	.team-avatar {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50rpx;
	
	}
	.team-nickname{
		margin-left: 20rpx;
		line-height: 50rpx;
	}
	.team-list{
		margin-top: -60rpx;
		padding: 0 30rpx;
		height:100rpx;
	}
	.item-list-block{
		background:#fff;
		padding:20rpx 40rpx;
		border-radius: 20rpx;
		box-shadow: 2rpx 2rpx 1rpx #eeeeee;
	}
	.item-info:last-child{
		border:none
	}
	.item-info{
		display: flex;
		box-sizing: border-box;
		align-items: center;
	
		border-bottom: 1px solid #f1f1f1;
		padding:20rpx 0;
	}
	.item-faces{margin-right: 20rpx;}
	.item-name{
		font-size: 30rpx;color:#545454;width:41%;
	}
	.item-name-nick{display: flex;box-sizing: border-box;
		align-items: center;
		}
	.item-time{font-size: 20rpx;color:#b5b5b5;
	display: flex;
	box-sizing: border-box;}
    .level_name{border-radius: 17rpx;
	background:#f00;display: block;font-size: 20rpx;color:#fff;text-align: center;
	width:34rpx;height:34rpx;}
</style>
